package active.observers;

import active.observers.jdk.SubObservable;

import java.util.Observable;
import java.util.Observer;

public class ClientObserver {
    public static void main(String[] args) {
        Subject subject = new Subject();
        subject.attach(new BaiduObserver());
        TenXunObserver tenXunObserver = new TenXunObserver();
        subject.attach(tenXunObserver);
        subject.setState(1);
        subject.remove(tenXunObserver);
        subject.setState(2);

        // 测试jdk提供的
        Observer observer = new Observer() {
            @Override
            public void update(Observable o, Object arg) {
                System.out.println("1111");
            }
        };

        SubObservable observable = new SubObservable();
        observable.addObserver(observer);
        observable.setName("张三");
    }
}
